package cn.edu.scau.dao;

import cn.edu.scau.entity.Bed;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
@CacheNamespace
public interface BedMapper {
    @Delete({
        "delete from bed",
        "where bedID = #{bedid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer bedid);

    @Insert({
        "insert into bed (bedID, bedOccupyTatus, ",
        "bedDescription)",
        "values (#{bedid,jdbcType=INTEGER}, #{bedoccupytatus,jdbcType=BIT}, ",
        "#{beddescription,jdbcType=VARCHAR})"
    })
    int insert(Bed record);

    @InsertProvider(type=BedSqlProvider.class, method="insertSelective")
    int insertSelective(Bed record);

    @Select({
        "select",
        "bedID, bedOccupyTatus, bedDescription",
        "from bed",
        "where bedID = #{bedid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="bedID", property="bedid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="bedOccupyTatus", property="bedoccupytatus", jdbcType=JdbcType.BIT),
        @Result(column="bedDescription", property="beddescription", jdbcType=JdbcType.VARCHAR)
    })
    Bed selectByPrimaryKey(Integer bedid);

    @Select({
        "select",
        "bedID, bedOccupyTatus, bedDescription",
        "from bed"
    })
    @Results({
        @Result(column="bedID", property="bedid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="bedOccupyTatus", property="bedoccupytatus", jdbcType=JdbcType.BIT),
        @Result(column="bedDescription", property="beddescription", jdbcType=JdbcType.VARCHAR)
    })
    List<Bed> selectAll();

    
    @UpdateProvider(type=BedSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Bed record);

    @Update({
        "update bed",
        "set bedOccupyTatus = #{bedoccupytatus,jdbcType=BIT},",
          "bedDescription = #{beddescription,jdbcType=VARCHAR},",
        "where bedID = #{bedid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Bed record);
}